package com.np.activitydemo2;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.np.activitydemo2.entity.ArticleEntity;
import com.np.activitydemo2.entity.BlogEntity;

public class ArticleAddActivity extends AppCompatActivity {

    private EditText mInputTitle;
    private EditText mInputContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_article_add);

        mInputTitle = findViewById(R.id.input_title);
        mInputContent = findViewById(R.id.input_content);

        findViewById(R.id.button_add).setOnClickListener(v -> {
            ArticleEntity entity = new ArticleEntity();
            entity.setTitle(mInputTitle.getText().toString());
            entity.setContent(mInputContent.getText().toString());

            getIntent().putExtra("entity", entity);
            setResult(Activity.RESULT_OK, getIntent());

            finish();
        });
    }
}